package com.assignwork.modules.workarrange;

import com.assignwork.dto.WorkArrangeShipSearchDTO;
import com.assignwork.dto.WorkArrangeShipSubmitDTO;
import com.assignwork.service.IWorkArrangeShipService;
import com.assignwork.vo.PlanInfoVO;
import com.assignwork.vo.WorkArrangeShipPageVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName WorkArrangeShipController
 * @Description 航运配工前端控制器
 * @Author dujianyu
 * @Date 2023/12/21 15:51
 */
@RestController
@AllArgsConstructor
@RequestMapping("workArrange/ship")
public class WorkArrangeShipController extends BladeController {

    private IWorkArrangeShipService service;

    @PostMapping("submit")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增或修改", notes = "传入dto")
    public R<Boolean> submitWaShip(@RequestBody WorkArrangeShipSubmitDTO dto) {
        return R.status(service.submitWaShip(dto));
    }

    @GetMapping("/page")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入dto")
    public R<IPage<WorkArrangeShipPageVO>> waShipPage(WorkArrangeShipSearchDTO dto, Query query) {
        return R.data(service.selectWaShipPage(dto, Condition.getPage(query)));
    }

    @GetMapping("/list")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "列表", notes = "传入dto")
    public R<List<WorkArrangeShipPageVO>> waShipList(WorkArrangeShipSearchDTO dto) {
        return R.data(service.selectWaShipList(dto));
    }

    @PostMapping("/remove")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "删除", notes = "传入id")
    public R<Boolean> remove(@ApiParam(value = "主键集合", required = true) @RequestParam String id) {
        return R.status(service.removeWaShip(Func.toLong(id)));
    }

    @GetMapping("/getPlanInfo")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "获取计划信息", notes = "传入planId")
    public R<PlanInfoVO> getPlanInfo(WorkArrangeShipSearchDTO dto) {
        return R.data(service.getPlanInfo(dto));
    }

    @GetMapping("/getExistTeamId")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "获取计划信息", notes = "传入planId")
    public R<Long> getExistTeamId(WorkArrangeShipSearchDTO dto) {
        return R.data(service.getExistTeamId(dto));
    }
}
